﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TraHangUngDiShow.ascx.cs" Inherits="WebUserControl_TraHangUngDiShow" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>


<%@ Register src="uscMsgBox.ascx" tagname="uscMsgBox" tagprefix="uc1" %>
<%@ Import Namespace="BCDataCenter" %>
<link rel="stylesheet" href='<%=ResolveUrl("~/LayoutCss/datePicker.css")%>' type="text/css" />
<script type="text/javascript"  src='<%=ResolveUrl("~/JScript/jquery.alphanumeric.js")%>'></script>
<link rel="stylesheet" href='<%=ResolveUrl("~/LayoutCss/K_BaoCaoFormLayout.css")%>' type="text/css" />

<style type="text/css">
        .AutoExtender
        {
            font-family: Verdana, Helvetica, sans-serif;
            font-size: .8em;
            font-weight: normal;
            border: solid 1px #006699;
            line-height: 20px;
            padding: 10px;
            background-color: White;
            margin-left:10px;
            width: 300px;
        }
        .AutoExtenderList
        {
            border-bottom: dotted 1px #006699;
            cursor: pointer;
            color: Maroon;
        }
        .AutoExtenderHighlight
        {
            color: White;
            background-color: #006699;
            cursor: pointer;
        }
        #divwidth
        {
         width: auto !important;    
        }
        #divwidth div
       {
        width: auto !important;   
       }
        #div1
        {
         width: auto !important;    
        }
        #div1 div
       {
        width: auto !important;   
       }
       #divwidthMaHangInput
       {
       	width: auto !important;  
       }
        #divwidthMaHangInput div
       {
       	width: auto !important;  
       } 
       
 </style>

<script type="text/javascript">
    function PrintedOrder() {            
        window.open('Print.aspx', 'PrintMe', 'height=900px,width=900px,scrollbars=1');        
    }
    function SetTarget() {

        document.forms[0].target = "_blank";

    } 
   
     function pageLoad() {
      $("#<%= txtChietKhau.ClientID %>").numeric({allow:"."});
      $(function()
        {
	            $("#<%= txtNgayHD.ClientID %>").datePicker(
	                {
	                    clickInput:true,
			            startDate: '01/01/1970'
	                }
	                );
        });
        
      $(function()
        {
	            $("#<%= txtFromDay.ClientID %>").datePicker(
	                {
	                    clickInput:true,
			            startDate: '01/01/1970'
	                }
	                );
        });
	            
	            $("#<%= txtFromDay.ClientID %>").bind(
		            'dpClosed',function(e, selectedDates)
		                        {
			                        var d = selectedDates[0];
			                        if (d) {
				                            d = new Date(d);
				                            $("#<%= txtToDay.ClientID %>").dpSetStartDate(d.addDays(0).asString());
			                                }
		                        }
	                    );
	                    
	     $(function()
        {
	            $("#<%= txtToDay.ClientID %>").datePicker(
	                {
	                    clickInput:true
			           
	                }
	                );
        });
	
	          $("#<%= txtToDay.ClientID %>").bind(
		           'dpClosed',function(e, selectedDates)
		                        {
			                        var d = selectedDates[0];
			                        if (d) {
				                            d = new Date(d);
				                            $("#<%= txtFromDay.ClientID %>").dpSetEndDate(d.addDays(0).asString());
			                                }
		                        }
	            );

     
      $("#<%= btnNew.ClientID %>").click(function() { 
        $.blockUI({
             message: '<h1>Xin vui lòng chờ xử lý</h1>', 
            css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#f00', 
            opacity: .5, 
            color: '#fff' 
        } }); 
        }); 
        $("#<%= btnSave.ClientID %>").click(function() { 
        $.blockUI({
             message: '<h1>Xin vui lòng chờ xử lý</h1>', 
            css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#f00', 
            opacity: .5, 
            color: '#fff' 
        } }); 
        }); 
      $("#<%= btnDelete.ClientID %>").click(function() { 
        $.blockUI({
             message: '<h1>Xin vui lòng chờ xử lý</h1>', 
            css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#f00', 
            opacity: .5, 
            color: '#fff' 
        } }); 
        }); 
        
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
                function EndRequestHandler(sender, args) {
                        $.unblockUI();
                }
        }  
  

</script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" RenderMode="Block" >
    <ContentTemplate>
     <fieldset>
    <legend>Trả hàng từ BA</legend>
    </fieldset>
   <asp:Panel ID="Panel4" runat="server" BackColor="#EBEBEB" 
                        BorderStyle="None" Height="33px" Width="100%">
                                         <asp:ImageButton ID="btnNew" runat="server" Width="25px" Height="25px" ToolTip="Tạo hóa đơn mới" 
                                            ImageUrl="~/WebMaster/Images/Document.png" onclick="btnNew_Click" />
                                        &nbsp;
                                        <asp:ImageButton ID="btnSave" runat="server" Width="25px" Height="25px" ToolTip="Lưu hóa đơn"
                                            ImageUrl="~/WebMaster/Images/Save.png" onclick="btnSave_Click" /> 
                                        &nbsp;  
                                        <asp:ImageButton ID="btnDelete" runat="server" Width="25px" Height="25px" ToolTip="Xóa đơn hàng"
                                            ImageUrl="~/WebMaster/Images/Symbol-Delete.png" Visible="false" onclick="btnDelete_Click" /> 
                                        <input name="txtNgayMinHD" id="txtNgayMinHD" type="hidden" runat="server" /> 
    </asp:Panel>
            <br />
           <cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" 
            BackColor="#CCFFFF" Font-Names="Arial"  Height="720px" 
            Width="850px">
            
            <cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="Nhập thông tin" TabIndex="0">
                <ContentTemplate>            
               <fieldset>                  
                    <div class="fm-req">
                       <label for="txtMaTuVanVien">Số HĐ:</label>
                       <asp:TextBox ID="txtSoHD" runat="server" Width="100px" BackColor="Yellow" ReadOnly="true"></asp:TextBox>
                    </div>
                    <div class="fm-req">
                       <label for="txtMaTuVanVien">Ngày HĐ:</label>
                       <asp:TextBox ID="txtNgayHD" runat="server" Width="100px"></asp:TextBox>
                    </div>
                    <div class="fm-req">
                       <label for="txtMaTuVanVien">Mã BA:</label>
                       <asp:TextBox ID="txtMaTVV" CausesValidation="false" AutoPostBack="true" OnTextChanged="txtMaTVV_TextChanged" runat="server" Width="100px" ></asp:TextBox>
                         <div ID="div1" style="overflow:scroll; height:150px; display: none;"></div>
                                            <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" 
                                                CompletionInterval="10" CompletionListCssClass="AutoExtender" 
                                                CompletionListElementID="div1" 
                                                CompletionListHighlightedItemCssClass="AutoExtenderHighlight" 
                                                CompletionListItemCssClass="AutoExtenderList" CompletionSetCount="12" 
                                                DelimiterCharacters="" Enabled="True" MinimumPrefixLength="1" 
                                                ServiceMethod="GetTuVanVienInfo" 
                                                ServicePath="~/Services/WebServiceNhapHoaDonBanHang.asmx" 
                                                TargetControlID="txtMaTVV">
                                            </cc1:AutoCompleteExtender>
                       <asp:TextBox ID="txtTenTVV" runat="server" ReadOnly="true"></asp:TextBox> 
                    </div>
                   <div class="fm-req">
                       <label for="txtMaTuVanVien">Thông tin BA:</label>                                                                                            
                       <asp:TextBox ID="txtThongTinTVV" runat="server" Width="300px"></asp:TextBox>                                     
                    </div>
                    <div class="fm-req">
                       <label for="txtMaTuVanVien">Chiết khấu %:</label>                                                   
                         <asp:TextBox ID="txtChietKhau" runat="server" Width="120px"></asp:TextBox><span><b>%</b></span>
                    </div>                           
                       <div class="fm-re">
                        <label for="txtMaTuVanVien">Doanh số trong tháng:</label>
                       <asp:TextBox ID="txtDSTrongThang" ReadOnly="true" BackColor="Yellow" runat="server" Width="150px"></asp:TextBox>
                       </div>
                 <div class="fm-re">      
                       <label for="txtMaTuVanVien">Doanh số toàn nhóm:</label>
                       <asp:TextBox ID="txtDSTN" ReadOnly="true" BackColor="Yellow" runat="server" Width="150px"></asp:TextBox>
                       </div>
                  <div class="fm-re">
                        <label for="txtMaTuVanVien">Số BA:</label>
                       <asp:TextBox ID="txtSoBA" ReadOnly="true" BackColor="Yellow" runat="server" Width="150px"></asp:TextBox>
                </div>                             
                  </fieldset>                         
               <br />                             
                                                    <asp:GridView ID="gvChiTietDonHang" runat="server" AutoGenerateColumns="False"
                                                        Width="100%">
                                                        <Columns>
                                                            <asp:TemplateField HeaderText="STT"  HeaderStyle-HorizontalAlign="Center"> 
                                                                <ItemTemplate> 
                                                                    <asp:Label ID="lblSTT" runat="server" Text='<%# Bind("STT") %>'></asp:Label> 
                                                                </ItemTemplate> 
                                                                <ItemStyle Width="15px" HorizontalAlign="Center" />
                                                            </asp:TemplateField>                                                                      
                                                            <asp:TemplateField HeaderText="Loại dòng">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lblLoaiDong" runat="server" 
                                                                        Text='<%# Bind("LoaiDong") %>'></asp:Label>
                                                                </ItemTemplate>                                        
                                                                <ItemStyle Width="70px" />
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Mã hàng">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lblMaHang" runat="server" Text='<%# Bind("MaHang") %>'></asp:Label>
                                                                </ItemTemplate>
                                                                <ItemStyle Width="70px" />
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Tên hàng">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lblTenHang" runat="server" Text='<%# Bind("TenHang") %>'></asp:Label>
                                                                </ItemTemplate>                                        
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Số lượng">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lblSoLuong" runat="server" Text='<%# Eval("SoLuong") %>'></asp:Label>
                                                                </ItemTemplate>
                                                                <ItemStyle Width="40px" />
                                                            </asp:TemplateField>
                                                            <asp:BoundField DataField="Gia" HeaderText="Gia" Visible="False" />
                                                            <asp:BoundField DataField="VAT" HeaderText="VAT" Visible="False" />
                                                            <asp:BoundField DataField="ThanhTien" HeaderText="ThanhTien" Visible="False" />                                    
                                                                                               
                                                        </Columns>
                                                        </asp:GridView>
                                                   
                                                    <asp:Label ID="Label1" runat="server" Text="Tổng tiền "></asp:Label>
                                                    <asp:TextBox ID="txtTongTien" runat="server" Width="200px" ReadOnly="true" Font-Bold="True" ForeColor="Red"></asp:TextBox>
                   </ContentTemplate>
            </cc1:TabPanel>
            <cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="Tìm kiếm đơn hàng chưa in" TabIndex="1">
                <ContentTemplate>
                                                    <asp:GridView ID="gvDonHangChuaIn" runat="server" AutoGenerateColumns="False" OnRowCommand="gvDonHangChuaIn_RowCommand">
                                                        <Columns>
                                                            <asp:TemplateField HeaderText="In ?">
                                                                <ItemTemplate>
                                                                    <asp:ImageButton Width="20px" Height="20px" ID="bntPrint" runat="server" CommandName="btnPrinted" 
                                                                        ImageUrl="~/WebMaster/Images/Printer.png" />                                                                                   
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:BoundField DataField="MaHD" HeaderText="Số ĐH" />
                                                            <asp:BoundField DataField="TenTVV" HeaderText="Tư vấn viên" />
                                                            <asp:BoundField DataField="TienHD" HeaderText="Tiền ĐH" DataFormatString="{0:###,###.###}" />
                                                            <asp:BoundField DataField="TienHD" HeaderText="Thanh toán" DataFormatString="{0:###,###.###}" />
                                                            <asp:TemplateField HeaderText="Chọn">
                                                                <ItemTemplate>
                                                                    <asp:LinkButton ID="btnSelect" runat="server" CommandName="Selected">Chọn</asp:LinkButton> 
                                                                </ItemTemplate>
                                                            </asp:TemplateField>                                    
                                                        </Columns>
                                                        </asp:GridView>                            
                                                 
                            
                        </ContentTemplate>
                    </cc1:TabPanel>
            <cc1:TabPanel ID="TabPanelFind" runat="server" HeaderText="Tìm kiếm hóa đơn của BA" TabIndex="2">
                       <ContentTemplate>
                       <fieldset>   
                                <div class="fm-req">
                                <label for="txtMaTuVanVien">Mã BA</label>         
                                <asp:TextBox ID="txtMaTVVFind" Width="100px" runat="server" AutoPostBack="True" OnTextChanged="txtMaTVVFind_TextChanged">
                                </asp:TextBox>
                                            <div ID="divwidth" style="overflow:scroll; height:150px; display: none;"></div>
                                            <cc1:AutoCompleteExtender ID="txtMaTVV_AutoCompleteExtender" runat="server" 
                                                CompletionInterval="10" CompletionListCssClass="AutoExtender" 
                                                CompletionListElementID="divwidth" 
                                                CompletionListHighlightedItemCssClass="AutoExtenderHighlight" 
                                                CompletionListItemCssClass="AutoExtenderList" CompletionSetCount="12" 
                                                DelimiterCharacters="" Enabled="True" MinimumPrefixLength="1" 
                                                ServiceMethod="GetTuVanVienInfo" 
                                                ServicePath="~/Services/WebServiceNhapHoaDonBanHang.asmx" 
                                                TargetControlID="txtMaTVVFind">
                                            </cc1:AutoCompleteExtender>
                               <asp:TextBox ID="txtTenTVVFind" runat="server" Width="200px"></asp:TextBox>
                                 </div>
                                  <div class="fm-req">
                                  <label for="txtMaTuVanVien">Từ ngày</label> 
                                            <asp:TextBox ID="txtFromDay" runat="server">
                                            </asp:TextBox>
                                  </div>
                                  <div class="fm-req">
                                  <label for="txtMaTuVanVien">Đến ngày</label> 
                                       <asp:TextBox ID="txtToDay" runat="server">      
                                       </asp:TextBox>
                                             <asp:ImageButton ID="ImageButtonFind" runat="server" Height="20px" 
                                                ImageUrl="~/WebMaster/Images/Find.png" OnClick="ImageButtonFind_Click" 
                                                ToolTip="Tìm kiếm" Visible="true" Width="25px" />
                                   </div>
                                    
                                   <br />
                                                <asp:GridView ID="gvDonHangFind" runat="server" AutoGenerateColumns="False" 
                                                    OnRowCommand="gvDonHangFind_RowCommand" Width="100%">
                                                    <Columns>
                                                        <asp:BoundField DataField="MaHD" HeaderText="Số ĐH" />
                                                        <asp:BoundField DataField="TenTVV" HeaderText="Tư vấn viên" />
                                                        <asp:BoundField DataField="TienHD" DataFormatString="{0:###,###.###}" 
                                                            HeaderText="Tiền ĐH" />
                                                        <asp:BoundField DataField="TienHD" DataFormatString="{0:###,###.###}" 
                                                                HeaderText="Thanh toán" />
                                                        <asp:TemplateField HeaderText="Chọn">
                                                            <ItemTemplate>
                                                                <asp:LinkButton ID="btnSelect" runat="server" CommandName="Selected">Chọn</asp:LinkButton>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                    </Columns>
                                                </asp:GridView>
                            </fieldset>                                           
                        </ContentTemplate>
                    </cc1:TabPanel>
    </cc1:TabContainer>
        <uc1:uscMsgBox ID="uscMsgBox1" runat="server" />
    </ContentTemplate>
</asp:UpdatePanel>
